package gui;

import init.AppLauncher;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Frame;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JScrollPane;

/**
 * 
 * @author Chrystopher
 * AppMainFrame = main frame of the application
 * Needs panels and other graphical elements.
 */
public class AppMainFrame extends Frame implements WindowListener{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3849214220390458530L;
	private AppMainPanel panel;
	
	public AppMainFrame(){
		super("Music Data Visualization");
		
		panel = new AppMainPanel();
		
		add(panel);
		addWindowListener(this);
        //maximize window on launch
        setExtendedState(getExtendedState() | Frame.MAXIMIZED_BOTH);
	}

	public void windowActivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowClosed(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowClosing(WindowEvent e) {
		System.exit(0);
	}

	public void windowDeactivated(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowDeiconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowIconified(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}

	public void windowOpened(WindowEvent e) {
		// TODO Auto-generated method stub
		
	}
		
	public void addView(IView view, String alignment){
		//if(alignment.equals(BorderLayout.CENTER)){
			/*
			 * inspired by: http://www.coderanch.com/t/346221/GUI/java/Adding-Scrollbar-JPanel
			 * wrap the view in a jscrollpane to dynamically display scroll bars (when needed).
			 */
			//JScrollPane scroll=new JScrollPane((Component) view);
			//scroll.getHorizontalScrollBar().addAdjustmentListener(this);

			
			//panel.add(scroll,alignment);

		//}
		//else{
			panel.add(view, alignment);
		//}
	}

	public AppMainPanel getPanel() {
		return panel;
	}

	public void setPanel(AppMainPanel panel) {
		this.panel = panel;
	}

	//@Override
	//public void adjustmentValueChanged(AdjustmentEvent arg0) {
		//AppLauncher.bsv.repaint();
		
	//}
}
